Fix crash in daemon mode on new import cycle#14508
Merged
JukkaL merged 1 commit intopython:masterfrom Jan 23, 2023
Merged
Conversation
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
JukkaL
approved these changes
Jan 23, 2023
Collaborator
JukkaL
left a comment
There was a problem hiding this comment.
Great detective work! Looks good.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14329
This fixes the second crash reported in the issue (other one is already fixed). This one is tricky, it looks like it happens only when we bring in a new import cycle in an incremental update with
--follow-import=normal. To explain the reason, a little reminder of how semantic analyzer passes work:force_progressflag was added todefer().force_progress=True(without checking if we actually resolved some placeholder types).becomes_typeinfo=True, there is no way this symbol will later be unresolved (otherwise how would we know this is something that is a type).becomes_typeinfo=Truefor symbols imported from modules that were not yet processed, thus causing a crash (see test cases).becomes_typeinfo=Truefor unimported symbols in daemon mode, other one is to always carefully check if in-place update of a symbol actually resulted in progress.I didn't add test cases for each of the crash scenarios, since they are all very similar. I only added two that I encountered "in the wild", upper bound and tuple base caused actual crash in
triostubs, plus also randomly a test for a TypedDict crash.EDIT: and one more thing, the "cannot resolve name" error should never appear in normal mode, only in daemon update (see reasoning above), so I don't make those error messages detailed, just add some minimal info if we will need to debug them.